#include "../myOS/userInterface.h"
#include "shell.h"
#include "../myOS/include/myPrintk.h"
#include "../myOS/include/tasktype.h"

int tsk0_exet, tsk1_exet, tsk2_exet;

void SetExeTime(int tsk0, int tsk1, int tsk2)
{
	tsk0_exet = tsk0;
	tsk1_exet = tsk1;
	tsk2_exet = tsk2;
	return;
}

void tstcase0()
{
	for (int i = 0; i < 3; i++)
	{
		myPrintk(0x1, "task0 exe: %d/%d\n", i + 3, 5);
		delay();
	}
	return;
}

void testcase0(void)
{

#if DEBUG_QUEUE_FALGS
	myPrintf(0x08, "\nPress any key to continue debug:\n");
	uart_get_char();
#endif

	myPrintf(0x1, "|           New Task 0          |\n");
	myPrintf(0x1, "|   0 warning(s),  0 error(s)   |\n");

	int flag = 0;
	while (flag < tsk0_exet)
	{
		myPrintf(0x1, "task0 exe: %d/%d\n", flag + 1, tsk0_exet);
		flag++;
		delay();
	}

	return;
}

void testcase1(void)
{

#if DEBUG_QUEUE_FALGS
	myPrintf(0x08, "\nPress any key to continue debug:\n");
	uart_get_char();
#endif

	myPrintf(0x2, "|           New Task 1          |\n");
	myPrintf(0x2, "|           Bugs -= 1;          |\n");

	int flag = 0;
	while (flag < tsk1_exet)
	{
		myPrintf(0x2, "task1 exe: %d/%d\n", flag + 1, tsk1_exet);
		flag++;
		delay();
	}

	return;
}

void testcase2(void)
{

#if DEBUG_QUEUE_FALGS
	myPrintf(0x08, "\nPress any key to continue debug:\n");
	uart_get_char();
#endif

	myPrintf(0x3, "|           New Task 2          |\n");
	myPrintf(0x3, "|           Bugs -= 2;          |\n");

	int flag = 0;
	while (flag < tsk2_exet)
	{
		myPrintf(0x3, "task2 exe: %d/%d\n", flag + 1, tsk2_exet);
		flag++;
		delay();
	}

	return;
}

void shell(void)
{

#if DEBUG_QUEUE_FALGS
	myPrintf(0x08, "\nPress any key to continue debug:\n");
	uart_get_char();
#endif

	myPrintk(0x5, "|           Shell Task          |\n");
	myPrintk(0x5, "|         make  succeed!        |\n");
	startShell();
	return;
}
